const components = {}
const srcContext = require.context('@/components', true, /\.vue$/)
srcContext.keys().forEach(item => {
  let component = srcContext(item).default
  if (!component.name) {
    component.name = item.split('/').pop().replace(/\.vue$/, '')
  }
  components[component.name] = component
})
const install = function (Vue) {
  for (let name in components) {
    Vue.component(name, components[name])
  }
}

export default {
  install,
  components
}
